import React, { Component } from 'react';
import { Button, Modal, message } from 'antd';

export default class Delete extends Component {
  confirmDelete = () => {
    const { temId } = this.props;
    Modal.confirm({
      title: '要删除该暂存信息吗',
      cancelText: '取消',
      okText: '确定',
      onOk: () => {
        this.delete(temId);
      },
    });
  };

  delete = temId => {
    const { dispatch } = this.props;
    dispatch({
      type: 'createCompany/deleteForm',
      payload: temId,
    })
      .then(() => {
        message.success('删除成功');
      })
      .catch(errMsg => {
        message.error(errMsg);
      });
  };

  render() {
    return (
      <Button type="danger" onClick={this.confirmDelete}>
        删除
      </Button>
    );
  }
}
